<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增健身房会员')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-member-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">会员名：</label>
                <div class="col-sm-8">
                    <input name="memberName" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">性别：</label>
                <div class="col-sm-8">
                    <select name="memberSex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">会员手机号：</label>
                <div class="col-sm-8">
                    <input name="memberIphone" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">教练：</label>
                <div class="col-sm-8">
                    <select id="coach" class="form-control select2-multiple">
                        <option th:each="coach:${coaches}" th:value="${coach.coachId}" th:text="${coach.coachName}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">地区：</label>
                <div class="col-sm-8">
                    <select id="region" class="form-control select2-multiple">
                        <option th:each="region:${regiones}" th:value="${region.regionId}" th:text="${region.regionName}"></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "system/member"
        $("#form-member-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var data = $("#form-member-add").serializeArray();
	        	var coachIds = $.form.selectSelects("coach");
	        	var regionIds = $.form.selectSelects("region");
	        	data.push({"name": "regionId", "value": regionIds});
	        	data.push({"name": "coachId", "value": coachIds});
                $.operate.save(prefix + "/add", data);
            }
        }
    </script>
</body>
</html>